﻿<UserControl x:Class="MvvmCodeReduction.CustomerMVVM"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:MvvmCodeReduction"
             mc:Ignorable="d">
    <UserControl.Resources>
        <local:BoolToVisibilityConverter FalseValue="Collapsed"
                                         x:Key="btvc" />
    </UserControl.Resources>
    <Border Name="border"
            BorderBrush="Aqua"
            CornerRadius="5"
            BorderThickness="1"
            Padding="5"
            Margin="5">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding Model.Name}"
                       Visibility="{Binding IsNotEditing, 
                        Converter={StaticResource btvc}}" />
            <TextBox Text="{Binding EditedName}"
                     Visibility="{Binding IsEditing, 
                        Converter={StaticResource btvc}}" />
            <Button Content="{Binding EditCommandText}"
                    Command="{Binding EditCommand}"
                    Grid.Column="1" />
            <Button Content="Save"
                    Command="{Binding SaveCommand}"
                    IsEnabled="{Binding IsEditing}"
                    Grid.Column="2" />
        </Grid>
    </Border>
</UserControl>